<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="chapter" content="bp">

    <!-- For Facebook Sharing -->
    <meta property="og:url" content="http://students.brown.edu/seeing-theory/basic-probability/" />
    <meta property="og:type" content="article" />
    <meta property="og:title" content="Basic Probability" />
    <meta property="og:description" content="This chapter is an introduction to the basic concepts of probability theory." />
    <meta property="og:image" content="http://students.brown.edu/seeing-theory/img/share/1.png" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />



    <title>Seeing Theory - Basic Probability</title>
    <!-- CSS Imports -->
    <!--Fonts-->
    <link href="https://fonts.googleapis.com/css?family=Assistant:300,400,600,700" rel="stylesheet">
    <!--Font Awesome-->
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <!--Favicon-->
    <link rel="shortcut icon" type="image/png" href="../img/favicon.png" />
    <!-- General Chapter -->
    <link rel="stylesheet" type="text/css" href="../css/chapter-style.css">
    <!-- Specific Chapter -->
    <link rel="stylesheet" type="text/css" href="basic-probability.css">
    <!-- JavaScript Imports -->
    <!-- D3 -->
    <script src="../js/d3.min.js"></script>
    <!-- Jquery -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <!-- jstat -->
    <script src="../js/jstat.min.js"></script>
    <!-- MathJax -->
    <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"></script>
    <!-- Tool Tip -->
    <script src="../js/d3.tip.v0.6.3.js"></script>
    <!-- General Chapter -->
    <script src="../js/chapter.js"></script>
    <!-- Visualizations -->
    <script src="basic-probability.js"></script>
    <!-- Google Analytics -->
    <script>
    (function(i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function() {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
            m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
    ga('create', 'UA-85617614-1', 'auto');
    ga('send', 'pageview');


    </script>
</head>

<body id='1'>
    <div id="share-modal"></div>
    <div class="header">
        <div class="progress-bar">
            <div class="progress-bar-color"></div>
        </div>
        <div class="header-wrapper">
            <ul class="chapter-nav">
                <li>
                    <span onclick="openNav()" id="hamburger">&#9776; </span>
                </li>
                <li><a href="../index.html" id="seeing-theory">Seeing Theory</a></li>
                <li><a onclick='toTop()' id='display-chapter'>Chapter 1: Basic Probability</a></li>
            </ul>
        </div>
    </div>
    <div class="col-left">
        <div class="col-left-wrapper">
            <div id="section0">
                <div class="chapter-intro">
                    <h4>Chapter 1</h4>
                    <h1>Basic Probability</h1>
                    <p>This chapter is an introduction to the basic concepts of probability theory.
                    </p>
                </div>
                <div class="scroll-down"> <img src="../img/button/bottom-arrow.svg"></div>
            </div>
            <div id="section1">
                <div class="unit">
                    
                        <h3 >Chance Events </h3>
                        
 
                    
                    <p>Randomness is all around us. Probability theory is the mathematical framework that allows us to analyze chance events in a logically sound manner. The probability of an event is a number indicating how likely that event will occur. This number is always between 0 and 1, where 0 indicates impossibility and 1 indicates certainty.</p> 
                    <p>A classic example of a probabilistic experiment is a fair coin toss, in which the two possible outcomes are heads or tails. In this case, the probability of flipping a head or a tail is 1/2. In an actual series of coin tosses, we may get more or less than exactly 50% heads. But as the number of flips increases, the long-run frequency of heads is bound to get closer and closer to 50%.</p>
                    <div class="interactive-wrapper">
                        <div id="coinWrapper">
                            <div id="coin"></div>
                            <div id="coinButtons">
                                <div class="button-1" id="flipOne">Flip the Coin</div>
                                <div class="button-1" id="flipHundred">Flip 100 times</div>
                            </div>
                        </div>
                    </div>
                    <p> For an unfair or weighted coin, the two outcomes are not equally likely. You can change the weight or distribution of the coin by dragging the true probability bars (on the right in <span class="blue-color">blue</span>) up or down. If we assign numbers to the outcomes — say, 1 for heads, 0 for tails — then we have created the mathematical object known as a <a href="../probability-distributions/index.html#section1">random variable</a>.</p>
                </div>
            </div>
            <div id="section2">
                <div class="unit">
                    <h3>Expectation</h3>
                    <p>The expectation of a random variable is a number that attempts to capture the center of that random variable's distribution. It can be interpreted as the long-run average of many independent samples from the given distribution. More precisely, it is defined as the probability-weighted sum of all possible values in the random variable's support,</p>
                    <span id="centered">$$\text{E}[X] = \sum_{x \in \mathcal{X}}xP(x)$$</span>
                    <p>Consider the probabilistic experiment of rolling a fair die and watch as the running sample mean converges to the expectation of 3.5.</p>
                    <div class="interactive-wrapper">
                    <div id="dieWrapper">
                        <div id="die"></div>
                        <div id="dieButtons">
                            <div class="button-1" id="rollOne">Roll the Die</div>
                            <div class="button-1" id="rollHundred">Roll 100 times</div>
                        </div>
                    </div></div>
                    <p>Change the distribution of the different faces of the die (thus making the die biased or "unfair") by adjusting the <span class="blue-color">blue</span> bars below and observe how this changes the expectation.</p>
                    <div id="barDie"></div>
                </div>
            </div>
            <div id="section3">
                <div class="unit">
                    <h3>Variance</h3>
                    <p>Whereas expectation provides a measure of centrality, the variance of a random variable quantifies the spread of that random variable's distribution. The variance is the average value of the squared difference between the random variable and its expectation,</p>
                    <span id="left-mathjax">$$\text{Var}(X) = \text{E}[(X - \text{E}[X])^2]$$</span>
                    <p>Draw cards randomly from a deck of ten cards. As you continue drawing cards, observe that the running average of squared differences (in <span class="green-color">green</span>) begins to resemble the true variance (in <span class="blue-color">blue</span>).</p>
                    <div class="interactive-wrapper">
                        <div id="cardWrapper">
                            <div id="card"></div>
                            <div id="cardButtons">
                                <div class="button-1" id="drawOne">Draw a Card</div>
                                <div class="button-1" id="drawHundred">Draw 100 times</div>
                            </div>
                        </div>
                    </div>
                    <p>Toggle which cards you want to include in the deck by clicking on them below.</p>
                     <div class="interactive-wrapper">
                     </br>
                    <input type="checkbox" class="deck" id="card_one" value="1">
                    <label for="card_one"></label>
                    <input type="checkbox" class="deck" id="card_two" value="2">
                    <label for="card_two"></label>
                    <input type="checkbox" class="deck" id="card_three" value="3">
                    <label for="card_three"></label>
                    <input type="checkbox" class="deck" id="card_four" value="4">
                    <label for="card_four"></label>
                    <input type="checkbox" class="deck" id="card_five" value="5">
                    <label for="card_five"></label>
                    <input type="checkbox" class="deck" id="card_six" value="6">
                    <label for="card_six"></label>
                    <input type="checkbox" class="deck" id="card_seven" value="7">
                    <label for="card_seven"></label>
                    <input type="checkbox" class="deck" id="card_eight" value="8">
                    <label for="card_eight"></label>
                    <input type="checkbox" class="deck" id="card_nine" value="9">
                    <label for="card_nine"></label>
                    <input type="checkbox" class="deck" id="card_ten" value="10">
                    <label for="card_ten"></label>
                    </div>
                </div>
            </div>
        </div>
        <div class="action-buttons">
            
            <ul>
                <a href="../doc/basic-probability.pdf">
                    <li><i class="fa fa-file-text-o action-icon" aria-hidden="true"></i> <span>Download</span></li>
                </a>
                <a id="share-button" >

                    <li class="inline-share">
                        <i class="fa fa-share-square-o action-icon" aria-hidden="true"></i>Share
                    </li>
                    <li><div id="share-modal"></div></li>

                </a>

            </ul>
        </div>
        <a href="../compound-probability/index.html">
            <div class="chapter-footer" id="next-chapter-color">
                <div class="chapter-footer-wrapper">
                    <h4>Next</h4>
                    <p id='next-chapter'>Compound Probability → </p>
                </div>
            </div>
        </a>
    </div>
    <div class="col-right">
        <div class='language-setting'>
            <select class="languageSetting">
                <option selected>English</option>
                <option data-url="cn.html">中文</option>
                <option data-url="es.html">Español</option>
            </select>
        </div>
        <div class="nav-section" id="section-0">
            <div class="nav-unit-wrapper" id='one'>
                <img src="../img/tiles/1-1.png">
                <span class="nav-unit-title"> Chance Events </span>
            </div>
            <div class="nav-unit-wrapper" id='two'>
                <img src="../img/tiles/1-2.png">
                <span class="nav-unit-title"> Expectation </span>
            </div>
            <div class="nav-unit-wrapper" id='three'>
                <img src="../img/tiles/1-3.png">
                <span class="nav-unit-title"> Variance </span>
            </div>
        </div>
        <div class="visualization-section" id="section-1">
            <div class="visualization-wrapper" id="barCoin"></div>
        </div>
        <div class="visualization-section" id="section-2">
            <div class="visualization-wrapper" id="plotDie"></div>
        </div>
        <div class="visualization-section" id="section-3">
            <div class="visualization-wrapper" id="varSvg"></div>
        </div>
    </div>
    <div id="overlay">
        <div class="modal-header">
            <div class="closebtn" onclick="closeNav()">&times;</div>
            <ul>
                <li>
                    <select class="languageSetting">
                        <option selected>English</option>
                        <option data-url="cn.html">中文</option>
                        <option data-url="es.html">Español</option>
                    </select>
                </li>
                <li><a href="../index.html">HOME</a></li>
            </ul>
        </div>
        <div class="modal-wrapper">
            <div class="modal-chapter">
                <div id="chapter-text"><span>CHAPTER</span></div>
                <ul class="modal-chapter-titles">
                    <li id="bp-li" class="chapter-highlighted">Basic Probability</li>
                    <li id="cp-li">Compound Probability</li>
                    <li id="pd-li">Probability Distributions</li>
                    <li id="fi-li">Frequentist Inference</li>
                    <li id="bi-li">Bayesian Inference</li>
                    <li id="ra-li">Regression Analysis</li>
                </ul>
            </div>
            <div class="modal-visualization">
                <div id="bp" class="current">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/1-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Chance Event </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/1-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Expectation </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/1-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Variance </span>
                    </div>
                </div>
                <div id="cp">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/2-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Set Theory </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/2-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Counting </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/2-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Conditional Probability </span>
                    </div>
                </div>
                <div id="pd">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/3-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Random Variable </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/3-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Discrete and Continuous </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/3-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Central Limit Theorem </span>
                    </div>
                </div>
                <div id="fi">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/4-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Point Estimation </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/4-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Confidence Interval </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/4-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> The Bootstrap </span>
                    </div>
                </div>
                <div id="bi">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/5-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Bayes' Theorem </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/5-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Likelihood Function </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/5-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Prior to Posterior </span>
                    </div>
                </div>
                <div id="ra">
                    <div class="nav-unit-wrapper-s tile1">
                        <img src="../img/tiles/6-1.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Ordinary Least Squares </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile2">
                        <img src="../img/tiles/6-2.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Correlation </span>
                    </div>
                    <div class="nav-unit-wrapper-s tile3">
                        <img src="../img/tiles/6-3.png" class="nav-unit-tile-s">
                        <span class="nav-unit-title-s"> Analysis of Variance </span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="share"></div>
    <!-- Share CSS and JavaScript -->
    <link rel="stylesheet" type="text/css" href="../css/jssocials.css" />
    <link rel="stylesheet" type="text/css" href="../css/jssocials-theme-flat.css" />
    <script src="../js/jssocials.min.js"></script>
    <script>
       

        $("#share").jsSocials({
            // url: "_url_",
            // _createShareLink: function(share) {
            //     var $result = jsSocials.Socials.prototype._createShareLink.apply(this, arguments);
            //     $result.on("click", function() {
            //           // replace the your placeholder with actual url
            //           var href = $result.attr("href");
            //           $result.attr("href", href.replace("_url_", shareUrl));
            //     });
            //     return $result;
            // },
            showLabel: false,
            showCount: false,
            shareIn: "popup",
            shares: ["email", "twitter", "facebook", "googleplus", "linkedin"]
        });

        

        $(".languageSetting").change(function() {
          var option = $(this).find('option:selected');
          window.location.href = option.data("url");
        });
    </script>
</body>

</html>